<template>
  <div id="app">
	<h1>{{ msg }}</h1>
	<h1>{{ reversedMsg }}</h1>
	<hr>
	<MySearch @onSearch="getSearchWord"/> <!-- 获取搜索组件输入的值 -->
	<!-- <MyCounter></MyCounter> -->
	<!-- <hr> -->
	<!-- <MyCounter my-title="first"></MyCounter> -->
	<!-- <MyCounter my-title="二"/> -->
	<!-- <my-counter :my-title="san"></my-counter> -->
	<!-- <my-counter :my-title="si"/> -->
	<!-- <button @click="updateSi">update si</button> -->
	<!-- v-if  vs  v-show -->
    <!-- <img v-if="isShowLogo" alt="Vue logo" src="./assets/logo.png"> -->
	<!-- <button @click="toggleLogo">toggle logo</button> -->
  </div>
</template>

<!-- 
父子组件传值用自定义属性 props 
props 属于单项数据流 父 -> 子  
 
 
子父组件传值用自定义事件 this.$emit("事件名")
子 -> 父  
 -->

<script>
import MySearch from "./components/MySearch.vue"
// import MyCounter from "./components/MyCounter.vue"
	
// 最顶层的组件
export default {
  name: 'App',
  // 局部注册组件，只能在当前的 .vue 文件里用
  components: {
	MySearch,
	// MyCounter: MyCounter
	// MyCounter,
	// "组件名": 组件
  },
  data() { // 组件内data是一个函数，
	return {
		msg: "hello vue",
		isShowLogo: true,
		san: "33",
		si: "04"
	}
  },
  computed: {
	reversedMsg() {
		return this.msg.split("").reverse().join("")
	}
  },
  methods: {
	getSearchWord(data) {
		console.log(data)
		console.log("出发了父组件的事件")
	},
	toggleLogo() {
		this.isShowLogo = !this.isShowLogo
		console.log(this.isShowLogo)
	},
	updateSi() {
		this.si = this.si.repeat(2)
	}
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
}
</style>
